﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;

namespace YmtAuth.Domain.Repository
{
    public interface _IMsSqlRepository<TEntity> where TEntity : class
    {
        TEntity First(dynamic where);
        long Insert(TEntity entity);
        long Insert(TEntity entity, bool ignoreDuplicate);
        void InsertAsync(TEntity entity, bool ignoreDuplicate);
        int Update(IDictionary<string, object> updateColumns, IDictionary<string, object> where);
        int Update(IDictionary<string, object> updateColumns, IDictionary<string, object> where, string updateTableName);
        int Execute(string sql, IDictionary<string, object> parameter);
        int Execute(string sql, DbParameter[] parameter, int? timeOut = null, CommandType? commandType = null);
        Task<int> InsertAsync(TEntity entity, IDictionary<string, object> vlues);
        int Insert(TEntity entity, IDictionary<string, object> vlues);
        IEnumerable<TEntity> Query(string sql, DynamicParameters parameters, int? timeOut = null,
            CommandType? commandType = null, bool buffered = true);

        IEnumerable<TEntity> Query<T1, T2, TEntity>(string sql, DynamicParameters parameters,
            Func<T1, T2, TEntity> convert,
            string splitOn, int? timeOut = null, CommandType? commandType = null,
            bool buffered = true);

        TEntity QueryMultiple(string sql, DbParameter[] parameters, Func<SqlMapper.GridReader, TEntity> convert,
            int? timeOut = null, CommandType? commandType = null,
            bool buffered = true);
    }
}
